# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=bleach
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}" "${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=2.1.3
pkgrel=1
pkgdesc="An easy whitelist-based HTML-sanitizing tool (mingw-w64)"
url="http://pypi.python.org/pypi/bleach"
arch=('any')
license=('Apache')
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=(${_realname}-${pkgver}.tar.gz::https://pypi.org/packages/source/b/${_realname}/${_realname}-$pkgver.tar.gz)
sha256sums=('eb7386f632349d10d9ce9d4a838b134d4731571851149f9cc2c05a9a837a9a44')


prepare() {
  cd "$srcdir"/

  for pver in {2,3}; do
    rm -rf python${pver}-build-${CARCH} | true
    cp -r "${_realname}-${pkgver}" "python${pver}-build-${CARCH}"
  done

}

build() {
  for pver in {2,3}; do
    msg "Python ${pver} build for ${CARCH}"
    cd "${srcdir}/python${pver}-build-${CARCH}"
    ${MINGW_PREFIX}/bin/python${pver} setup.py build
  done
}

package_python3-bleach() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3"
           "${MINGW_PACKAGE_PREFIX}-python3-html5lib")

  cd ${srcdir}/"python${pver}-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
}

package_python2-bleach() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2"
           "${MINGW_PACKAGE_PREFIX}-python2-html5lib")

  cd ${srcdir}/"python${pver}-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1
}

package_mingw-w64-i686-python2-bleach() {
  package_python2-bleach
}

package_mingw-w64-i686-python3-bleach() {
  package_python3-bleach
}

package_mingw-w64-x86_64-python2-bleach() {
  package_python2-bleach
}

package_mingw-w64-x86_64-python3-bleach() {
  package_python3-bleach
}
